.SUFFIXES:
.SUFFIXES: .ml .mll .mly .mli .cmi .cmo

all: ${PROG} clean1

${PROG}: $(MLS:.ml=.cmo) $(MLYS:.mly=.cmo) $(MLLS:.mll=.cmo) ${PROG}.cmo
	ocamlc -o $@ $?

$(MLLS:.mll=.cmo): $(MLYS:.mly=.cmi)

$(MLYS:.mly=.cmo): $(MLS:.ml=.cmi)

.mll.ml:
	ocamllex $<

.mly.mli .mly.ml .mly.cmi:
	ocamlyacc $<
	ocamlc -c $*.mli

.ml.cmi .ml.cmo:
	ocamlc -c $<

clean1:
	rm -rf $(MLYS:.mly=.ml) $(MLYS:.mly=.mli) $(MLLS:.mll=.ml) *.cmo *.cmi

clean2: clean1
	rm -rf ${PROG}

clean: clean1 clean2
